import sensor, image, display, time

sensor.reset() # 初始化sensor
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
#设置图像色彩格式，有RGB565色彩图和GRAYSCALE灰度图两种

sensor.set_framesize(sensor.QVGA) # 320*240大小的液晶屏
# 初始化lcd屏幕，lcdtype = 0为2.0寸屏幕，lcdtype = 1为2.8寸屏幕
lcd = display.SPIDisplay(width = 320, height = 240, refresh = 120, lcdtype = 0)
clock = time.clock()

while(True):
    clock.tick()
    img = sensor.snapshot().lens_corr(strength = 1.8, zoom = 1.0)
    img.draw_string(0, 0, "FPS:%0.1f" % clock.fps(), color = (255, 0, 0),\
                    mono_space = False, scale = 2)
    lcd.write(img) # 拍照并显示图像，参数x_scale = 2可对图像就地进行缩放
    print(clock.fps())
